package co.th.bjc.md.dbonline.control;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import co.th.bjc.md.dbonline.bean.RegionDBOnlineBean;
import co.th.bjc.md.helper.RegionHelper;
import co.th.bjc.md.model.Region;

public class RegionControl {

private static Logger _log = Logger.getLogger(CategoryDBOnlineControl.class);
	
	public List<RegionDBOnlineBean> findAllRegion() {
		List<RegionDBOnlineBean> list = new ArrayList<RegionDBOnlineBean>(0);
		try {
			List<Region> listRegion = new RegionHelper().findAllRegion();
			for (Region region : listRegion) {
				list.add(setModelToBean(region));
			}
		} catch (Exception ex) {
			_log.error("Exception : " + ex.getMessage());
			ex.printStackTrace();
		}
		return list;
	}
	
	private RegionDBOnlineBean setModelToBean(Region model){
		RegionDBOnlineBean bean = new RegionDBOnlineBean();
		bean.setRegionId(model.getRegionId());
		bean.setRegionNameTH(model.getRegionNameTH());
		bean.setRegionNameEN(model.getRegionNameEN());
		return bean;
	}
}
